add_filter( 'body_class', 'custom_class' );
function custom_class( $classes ) {
if ( is_page_template( 'page-example.php' ) ) {
$classes[] = 'example';
}
return $classes;
}
<body <?php body_class( 'class-name' ); ?>>